<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' encoding='UTF-8' doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent='yes'/>

	<!-- xml filesources -->
	<xsl:variable name="src_head" select="document(root/filehead/@src)"/>
	<xsl:variable name="src_header" select="document(root/fileheader/@src)"/>
	<xsl:variable name="src_navbar" select="document(root/filenavbar/@src)"/>
	<xsl:variable name="src_footer" select="document(root/filefooter/@src)"/>
	
	<!-- template to load a static content -->
	<xsl:template name="Loader">
		<xsl:param name="src"/>  
		<xsl:copy-of select="$src/root/*[name() != 'namespace']"/>
	</xsl:template>

	<!-- template to load extra data content -->
	<xsl:template name="ExtraDataLoader">
		<xsl:param name="src"/>
		<xsl:copy-of select="$src/*[name() != 'namespace']"/>
	</xsl:template>
	
	
	<!-- template to dinamically create menu -->
	<xsl:template name="NavLoader">
		<xsl:param name="src"/>
		<xsl:variable name="page" select="page"/>
		<!-- login -->
		<xsl:copy-of select="$src/root/linkable/a"/>
		<!-- navbar link list -->
		<ul id="nav_list">
			<xsl:if test="page = 'home'">
				<xsl:copy-of select="$src/root/not_linkable/ul/li[text()='Home']"/>
			</xsl:if>
			<xsl:if test="page != 'home'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='o']]"/>					
			</xsl:if>
			<xsl:if test="page = 'signup'">
				<xsl:copy-of select="$src/root/not_linkable/ul/li[text()='Sign Up']"/>
			</xsl:if>
			<xsl:if test="page != 'signup'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='s']]"/>
			</xsl:if>
			<xsl:if test="page = 'help'">
					<xsl:copy-of select="$src/root/not_linkable/ul/li[text()='Help']"/>
			</xsl:if>
			<xsl:if test="page != 'help'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='h']]"/>
			</xsl:if>
			<xsl:if test="page = 'about'">
				<xsl:copy-of select="$src/root/not_linkable/ul/li/a[text()='About']"/>
			</xsl:if>
			<xsl:if test="page != 'about'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='a']]"/>
			</xsl:if>
			<xsl:if test="page = 'sitemap'">
				<xsl:copy-of select="$src/root/not_linkable/ul/li/a[text()='Sitemap']"/>
			</xsl:if>
			<xsl:if test="page != 'sitemap'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='m']]"/>
			</xsl:if>
		</ul>
	</xsl:template>

	<!-- template to generate main content -->
	<xsl:template name="SignupContent">
		<!-- load extra tabindex params -->
		<xsl:call-template name="ExtraDataLoader">
			<xsl:with-param name="src" select="extradata/tabindex"/>
		</xsl:call-template>
		<!-- main tab page -->
		<div id="tab_wrapper">
			<p class="site_pos">You are here:  <a href="index.html">Home</a> -&gt; Sign Up</p>
			<!-- signup form -->
			<form action="/cgi-bin/signup.pl" id="signup_form" method="post">
				<h1>Sign Up form</h1>
				<p id="required"><span>Note:</span> items marked with * are required</p>
				<fieldset id="personal">
					<legend>Personal details</legend>
					<ul>
						<li><label for="first_name">first name<em>*</em> </label><input id="first_name" name="first_name"  type="text"/></li>
						<!-- first name error -->
						<xsl:if test="error/first_name = 'empty'">
							<span class="error_box" id="last_name_err">Required field</span>
						</xsl:if>
						<li><label for="last_name">last name<em>*</em> </label><input id="last_name" name="last_name" type="text" /></li>
						<li><label for="email">email<em>*</em> </label><input id="email" name="email" type="text" /></li>
						<li>
							<label>gender</label><input type="radio" name="gender" id="male-gender" value="male" />
							<label for="male-gender" class="inner_label">male</label><input type="radio" name="gender" checked="true" value="female" id="female-gender"/>
							<label for="female-gender"  class="inner_label" >female</label>
						</li>
					</ul>
				</fieldset>
				<fieldset id="account"><legend>Account details</legend>
					<ul>
						<li><label for="username">username<em>*</em> </label><input id="username" name="username" type="text" /></li>
						<li><label for="password">password<em>*</em> </label><input id="password" name="password" type="password" /></li>
						<li><label for="confirm_password">confirm password<em>*</em> </label><input id="confirm_password" name="confirm_password" type="password" /></li>
					</ul>
				</fieldset>  
				<input type="submit" id="submit" value="Submit!" onclick="if(!FormChecker.check()) return false;"/>
			</form>
		</div>
	</xsl:template>

	
	<!-- CREATE PAGE -->
	
	<!-- create page structure -->
	<xsl:template match="root">
		<html>
			<!-- head -->
			<head>
				<!-- load common code -->
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_head"/>
				</xsl:call-template>
				<!-- load extra head params -->
				<xsl:call-template name="ExtraDataLoader">
					<xsl:with-param name="src" select="extradata/head"/>
				</xsl:call-template>
				<!-- pagetitle -->
				<title><xsl:value-of select="pagetitle"/></title>
			</head>
			<body>
				<!-- header -->			
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_header"/>
				</xsl:call-template>
				<!-- navbar -->
				<div id="navbar">
					<xsl:call-template name="NavLoader">
						<xsl:with-param name="src" select="$src_navbar"/>
					</xsl:call-template>
				</div>
				<!-- content -->
				<xsl:call-template name="SignupContent">
					<xsl:with-param name="src" select="$src_footer"/>
				</xsl:call-template>				
				<!-- footer -->
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_footer"/>
				</xsl:call-template>				
			</body>
		</html>
	</xsl:template>
	
</xsl:stylesheet>
